package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.ShowLandEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.DateUtils;

import java.util.List;

/**
 * 土地推荐列表itme
 */
@Deprecated
public class ShowLeaseLandAdapter extends BaseRecycleAdapter<ShowLandEntity> {

    private TextView price_view;
    private TextView tv_area;
    private TextView tv_time;

    public ShowLeaseLandAdapter(Context context, List<ShowLandEntity> datas) {
        super(context, R.layout.item_show_lease_land, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final ShowLandEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        price_view = holder.itemView.findViewById(R.id.price_view);
        tv_area = holder.itemView.findViewById(R.id.tv_area);
        tv_time = holder.itemView.findViewById(R.id.tv_time);
        tv_area.setText(entity.getCityName() + " " + entity.getAreaName());

        try {
            double rentalPriceInt = Double.valueOf(entity.getRentalPrice());
            if (rentalPriceInt <= 0) {
                price_view.setText("面议");
            } else {
                price_view.setText(entity.getRentalPrice() + entity.getRentalSelectPriceName());
            }
        } catch (Exception e) {
            price_view.setText("面议");
        }
        try {
            tv_time.setText(DateUtils.stampToDay(entity.getUpdateTime()));
        } catch (NumberFormatException e) {

        }
    }
}
